Note that elements having unpaired electrons with parallel spins align themselves in a magnetic field. Such materials are referred to as paramagnetic materials and are attracted to an external magnetic field as long as a field is applied. When the external magnetic field is removed, the electrons in a paramagnetic material will reassume random orientations.
Elements with no unpaired electrons are diamagnetic and are weakly repelled by a magnetic field. The magnetic moments of the two paired electrons cancel each other out to cause this effect.
Iron belongs to a class of magnetic materials referred to as ferromagnetic. Ferromagnetic materials are similar to paramagnetic materials in that they have unpaired electrons but differ in that their magnetic moments permanently align themselves after exposure to an external magnetic field. Ferromagnetic materials will generate their own magnetic field after the external field is removed and are said to be magnetized.